<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">

</div>
<script src="../../js/vue.js"></script>
<script>

    const app = Vue.createApp({
        template: `
          <CountComponent></CountComponent>
        `,
    })

    app.component("CountComponent",{
        template: `
          <h1>计数器：{{ count }}</h1>
          <button @click="add">+1</button>
          <button @click="sub">-1</button>
        `,
        data() {
            return {
                count: 0
            }
        },
        methods: {
            add() {
                this.count++
            },
            sub() {
                this.count--
            },
        }
    })
    app.mount("#app")
</script>
</body>
</html>
